<script>
export default {
  name: "stockItem",
  data(){

  },
  beforeMount() {

  },
  methods:{

  }
}
</script>

<template>
  <div>
    <!--    按钮-->
    <div style="margin-bottom: 5px">
      <el-input v-model="number" placeholder="请输入单据编号" suffix-icon="el-icon-search" style="width: 200px"
                @keyup.enter.native="loadPost"></el-input>
      <el-button type="primary" style="margin-left: 5px" @click="loadPost">查询</el-button>
      <el-button type="success" @click="resetParam">重置</el-button>
      <el-button type="primary" style="margin-left: 5px" @click="add">新增</el-button>
    </div>

    <!--    表单-->
    <el-table :data="tableData" v-loading="loading"
              :header-cell-style="{background:'#f3f6fd',color:'#555'}">

      <el-table-column prop="operate" label="操作"  width="200">
        <template slot-scope="scope">
          <el-button size="small" type="success" @click="mod(scope.row)">编辑</el-button>
          <el-popconfirm
              title="确定删除吗？"
              style="margin-left: 5px;margin-right: 5px"
              @confirm="del(scope.row.id)"
          >
            <el-button slot="reference" size="small" type="danger" >删除</el-button>
          </el-popconfirm>
          <el-button size="small" type="success" v-if="usersession.position === '1' || usersession.position === '3' " @click="updateStatus(scope.row)" >审核</el-button>
        </template>
      </el-table-column>
      <el-table-column prop="organName" label="客户" width="140">
      </el-table-column>
      <el-table-column prop="number" label="单据编号" width="200">
      </el-table-column>
      <el-table-column prop="materialName" label="商品信息" width="120">
      </el-table-column>
      <el-table-column prop="createTime" label="创建时间" width="200">
      </el-table-column>
      <el-table-column prop="creatorName" label="操作员" width="120">
      </el-table-column>
      <el-table-column prop="operNumber" label="数量" width="120">
      </el-table-column>
      <el-table-column prop="taxLastMoney" label="合计金额" width="120">
      </el-table-column>
      <el-table-column prop="discount" label="优惠率" width="120">
      </el-table-column>
      <el-table-column prop="discountLastMoney" label="优惠后金额" width="120">
      </el-table-column>
      <el-table-column prop="status" label="状态" width="120">
        <template slot-scope="scope">
          <el-tag
              :type="scope.row.status === '1' ? 'success' : 'danger'"
              disable-transitions>{{scope.row.status === '1' ? '已审核' : scope.row.status === '2' ? '完成采购' : scope.row.status === '9' ? "审核中" : "未审核"}}
          </el-tag>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="pageNum"
        :page-sizes="[2, 5, 10, 20]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
    </el-pagination>

    <!--    外提示框-->
    <el-dialog
        title="提 示"
        :visible.sync="outerVisible"
        width="80%"
    >
      <el-form ref="form" :model="form" label-width="100px" size="mini" :rules="rules">
        <el-row>
          <el-col :span="6">
            <el-form-item label="客户" prop="selectedOrganId">
              <el-select v-model="selectedOrganId" @change="handleSelectChange" filterable placeholder="选择客户" style="margin-left: 5px">
                <el-option
                    v-for="(key,value) in hashMapUsers"
                    :key="value"
                    :label="key"
                    :value="value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="单据日期" prop="createTime">
              <el-date-picker
                  v-model="form.createTime"
                  type="datetime"
                  placeholder="选择日期时间"
                  style="margin-left: 5px">
              </el-date-picker>
            </el-form-item>
          </el-col>

          <el-col :span="6" style="margin-left: 10px">
            <el-form-item label="单据编号" prop="number" style="margin-left: 5px">
              <el-input v-model="form.number" placeholder="请输入单据编号" ></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-table :data="tableDatatable" ref="table">
          <el-table-column prop="productId" label="条码"  width="200">
            <el-input v-model="form.productId" size="mini" @keyup.enter.native="select(form.productId)">
              <el-button slot="append" icon="el-icon-search" @click="select(form.productId)"></el-button>
            </el-input>
          </el-table-column>
          <el-table-column prop="materialName" label="名称">
            <el-input v-model="form.materialName" :disabled="true"  size="mini"></el-input>
          </el-table-column>
          <el-table-column prop="currentNumber" label="库存">
            <el-input v-model.number="form.currentNumber" type="number" :disabled="true" size="mini"></el-input>
          </el-table-column>
          <el-table-column prop="materialUnit" label="单位">
            <el-input v-model="form.materialUnit" :disabled="true" size="mini"></el-input>
          </el-table-column>

          <el-table-column prop="operNumber" label="数量" >
            <template slot-scope="scope">
              <el-input v-model.number="form.operNumber"  type="number" size="mini"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="unitPrice" label="单价">
            <template slot-scope="scope">
              <el-input v-model.number="form.unitPrice"  type="number" size="mini"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="allPrice" label="金额">
            <template slot-scope="scope">
              <el-input v-model.number="form.allPrice" type="number" size="mini" disabled></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="taxRate" label="税率">
            <template slot-scope="scope">
              <el-input v-model.number="form.taxRate" placeholder="%" size="mini"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="taxMoney" label="税额">
            <template slot-scope="scope">
              <el-input v-model.number="form.taxMoney" type="number" size="mini" disabled></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="taxLastMoney" label="价税合计">
            <template slot-scope="scope">
              <el-input v-model.number="form.taxLastMoney" type="number" size="mini" disabled></el-input>
            </template>
          </el-table-column>
        </el-table>

        <el-form-item label="备注" prop="remark">
          <el-input
              type="textarea"
              placeholder="请输入备注"
              v-model="form.remark"
              maxlength="30"
              show-word-limit
              size="mini"
          >
          </el-input>
        </el-form-item>

        <el-row>
          <el-col :span="6">
            <el-form-item label="优惠率：" prop="discount">
              <el-input v-model="form.discount" placeholder="请输入优惠率"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="付款优惠：" prop="discountMoney">
              <el-input v-model="form.discountMoney" placeholder="请输入付款优惠" disabled></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="优惠后金额：" prop="discountLastMoney">
              <el-input v-model="form.discountLastMoney" placeholder="请输入付款优惠" disabled></el-input>
            </el-form-item>
          </el-col>
        </el-row>

      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="outerVisible = false">取 消</el-button>
        <el-button type="primary" @click="loadAdd">确 定</el-button>
      </span>
    </el-dialog>

    <!--    商品表单提示框-->
    <el-dialog
        title="选择商品"
        :visible.sync="innerVisible"
        width="60%"
    >
      <!--    商品表单-->
      <el-table :data="profucttableData" v-loading="loading"
                ref="multipleTable"
                :header-cell-style="{background:'#f3f6fd',color:'#555'}"
                @selection-change="handleSelectionChange">
        <el-table-column
            type="selection"
            width="55">
        </el-table-column>
        <el-table-column prop="barCode" label="条码" width="140">
        </el-table-column>
        <el-table-column prop="name" label="名称" width="140">
        </el-table-column>
        <el-table-column prop="standard" label="规格" width="120">
        </el-table-column>
        <el-table-column prop="model" label="型号" width="120">
        </el-table-column>
        <el-table-column prop="color" label="颜色" width="120">
        </el-table-column>
        <el-table-column prop="categoryId" label="类别" width="120">
        </el-table-column>
        <el-table-column prop="unit" label="单位" width="120">
        </el-table-column>
        <el-table-column prop="currentNumber" label="库存" width="120">
        </el-table-column>
      </el-table>
      <!--    分页-->
      <el-pagination
          @size-change="handleSizeChange1"
          @current-change="handleCurrentChange1"
          :current-page="pageNum1"
          :page-sizes="[2, 5, 10, 20]"
          :page-size="pageSize1"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total1">
      </el-pagination>

      <span slot="footer" class="dialog-footer">
        <el-button @click="innerVisible = false">取 消</el-button>
        <el-button type="primary" @click="copyProduct">确 定</el-button>
      </span>
    </el-dialog>



  </div>
</template>

<style scoped>

</style>